package cn.iocoder.yudao.module.system.repository.mybatis.dao.mail;

import cn.iocoder.yudao.common.pojo.PageResult;
import cn.iocoder.yudao.core.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.core.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.repository.mybatis.domain.mail.MailLog;
import cn.iocoder.yudao.module.system.vo.mail.log.MailLogPageReqVO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface MailLogMapper extends BaseMapperX<MailLog> {

    default PageResult<MailLog> selectPage(MailLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MailLog>()
                .eqIfPresent(MailLog::getUserId, reqVO.getUserId())
                .eqIfPresent(MailLog::getUserType, reqVO.getUserType())
                .likeIfPresent(MailLog::getToMail, reqVO.getToMail())
                .eqIfPresent(MailLog::getAccountId, reqVO.getAccountId())
                .eqIfPresent(MailLog::getTemplateId, reqVO.getTemplateId())
                .eqIfPresent(MailLog::getSendStatus, reqVO.getSendStatus())
                .betweenIfPresent(MailLog::getSendTime, reqVO.getSendTime())
                .orderByDesc(MailLog::getId));
    }

}
